/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Presentation.Model;

import DataAccess.entity.Criteria;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Domenico
 */
public class CriteriaTableModel extends DefaultTableModel {
    private ArrayList<Criteria> listaCriteri;
    
    public CriteriaTableModel(ArrayList<Criteria> lista) {
        super();
        addColumn("Nome Proprietà");
        addColumn("Condizione");
        addColumn("Valore");
        listaCriteri = lista;
        for (int i = 0; i < lista.size(); i++) {
            addRow(lista.get(i));
        }
    }
    public void addRow(Criteria c) {
        listaCriteri.add(c);
        Vector<String> vector = new Vector<String>();
        vector.add(c.getProperty().getFieldAlias());
        vector.add(c.getCondizione());
        vector.add(c.getValore());
        addRow(vector);
        
    }
    public void removeRow(int row) {
        listaCriteri.remove(row);
        removeRow(row);
    }
    public ArrayList<Criteria> getCriteria(){
        return listaCriteri;
    }
}
